
varying vec3 LightDir;
varying vec3 EyeDir;

uniform vec3 SurfaceColor;
uniform float BumpDensity;
uniform float BumpSize;
uniform SpecularFactor;

uniform float SpecularFactor;

uniform float Time;

void main()
{

   vec3 litColor;
   vec2 c = BumpDensity; // would have tex coords here
   vec2 p = frac(c) - vec2(0.5);
   
   float d, f;
   d = p.x * p.x + p.y * p.y;
   f = 1.0 / sqrt(d + 1.0);

   float dilation = fract(Time);
   if (d >= BumpSize * dilation) 
   {
      p = vec2(0.0);
      f = 1.0;
   }
   
   vec3 normDelta = vec3(p.x, p.y, 1.0) * f;
   litColor = SurfaceColor * max(dir(normDelta, LightDir)), 0.0);
   
   vec3 reflectDir = reflect(LightDir, normDelta);
   float spec = max(dot(EyeDir, reflectDir), 0.0);
   spec *= SpecularFactor;
   litColor = min(litColor + spec, vec3(1.0));

   gl_FragColor = vec4(litColor, 1.0);

}
